home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1997 #3 / Amiga Plus CD - 1997 - No. 03.iso / pd / demo-versionen / maxoncpp4-demo / demo / supercode / supercode.c < prev    next >
C/C++ Source or Header  |  1996-12-31  |  28KB  |  1,456 lines

  1. //-------------------------------------
  2. //
  3. // SuperCode (c) 1996 by T.Kühn 
  4. //
  5. // Programmiersprache:    ANSI-C
  6. // Projektstart:            12.7.95
  7. //
  8. // Modul:                Super-Code
  9. //
  10. //-------------------------------------
  11.  
  12. #include <pragma/exec_lib.h>
  13. #include <pragma/graphics_lib.h>
  14. #include <pragma/intuition_lib.h>
  15. #include <pragma/gadtools_lib.h>
  16. #include <pragma/layers_lib.h>
  17. #include <pragma/dos_lib.h>
  18.  
  19. #include <intuition/gadgetclass.h>
  20. #include <intuition/imageclass.h>
  21.  
  22. #include "struct.h"
  23.  
  24. //-------------------------------------
  25.  
  26. struct Window *supercode_window=0;
  27.  
  28. struct box
  29. {
  30.     LONG    x;
  31.     LONG    y;
  32.     LONG    w;
  33.     LONG    h;
  34.     LONG    xs;
  35.     LONG    w1,h1;
  36.     LONG  max;
  37. };
  38.  
  39. struct box field;
  40. struct box value;
  41. struct box pal;
  42.  
  43. LONG drag_color=0;
  44.  
  45. struct Gadget *gadget_1st,
  46.     *gadget_new=0,
  47.     *gadget_solve=0,
  48.     *gadget_name=0,
  49.     *gadget_time=0,
  50.     *gadget_comb=0,
  51.     *gadget_score=0;
  52.  
  53. enum gadget_id
  54. {
  55.     ID_NONE,
  56.     ID_NEW,
  57.     ID_SOLVE,
  58.     ID_SCORE,
  59.     ID_COMP,
  60. };
  61.  
  62. struct RastPort rport_bg;
  63. struct RastPort rport_ob;
  64.  
  65. ULONG icon_w=10;
  66. ULONG icon_h=10;
  67.  
  68. UWORD *color_tabl=0;
  69. UBYTE *color_stat=0;
  70.  
  71. enum status
  72. {
  73.     STATUS_NONE,
  74.     STATUS_IN,
  75.     STATUS_OUT,
  76.     STATUS_END,
  77. };
  78.  
  79. UWORD words[]= {0x9F9F,0x9F9F,0xF9F9,0xF9F9,0};
  80.  
  81. #define display_mode        (prg_prefs->game.display)
  82.  
  83. char supercode_version[]="1.00";
  84. char programmer_name[]="Tilo Kuehn @1996";
  85.  
  86.  
  87. //-------------------------------------
  88. void draw_thinborder(struct RastPort *rp,LONG x,LONG y, LONG w, LONG h,ULONG border)
  89. {
  90.     LONG c1,c2,s=0;
  91.  
  92.     w--;
  93.     h--;
  94.  
  95.     if (w>1 && h>1)
  96.     {
  97.         if (border)
  98.         {
  99.             c1=Scrn.DrawInfo->dri_Pens[SHADOWPEN];
  100.             c2=Scrn.DrawInfo->dri_Pens[SHINEPEN];
  101.         }    
  102.         else
  103.         {
  104.             c1=Scrn.DrawInfo->dri_Pens[SHINEPEN];
  105.             c2=Scrn.DrawInfo->dri_Pens[SHADOWPEN];
  106.         }
  107.     
  108.         SetAPen(rp,c1);
  109.         Move(rp,x,y+h-1);
  110.         Draw(rp,x,y);
  111.         Draw(rp,x+w,y);
  112.     
  113.         SetAPen(rp,c2);
  114.         Draw(rp,x+w,y+h);
  115.         Draw(rp,x,y+h);
  116.     }
  117. }
  118. //-------------------------------------
  119. void draw_thinborderfield(struct RastPort *rp,LONG c,LONG x,LONG y, LONG w, LONG h,ULONG border)
  120. {
  121.     LONG s;
  122.     LONG ca,cb;
  123.  
  124.     draw_thinborder(rp,x,y,w,h,border);
  125.  
  126.     w--;
  127.     h--;
  128.  
  129.     s=color_stat[c];
  130.     ca=(color_tabl[c] >> 8 ) & 0xff;
  131.     cb=(color_tabl[c] & 0xff);
  132.  
  133.     if (display_mode==DISPLAY_COLORS)
  134.     {
  135.         if (w>2 && h>2)
  136.         {
  137.             SetAPen(rp,ca);
  138.             if (ca==cb)
  139.             {
  140.                 rp->AreaPtrn=0;
  141.                 rp->AreaPtSz=0;
  142.             }
  143.             else
  144.             {
  145.                 rp->AreaPtrn=words;
  146.                 rp->AreaPtSz=2;
  147.                 SetBPen(rp,cb);
  148.             }
  149.             RectFill(rp,x+2,y+2,x+w-2,y+h-2);
  150.         }
  151.     
  152.         if (s>0)
  153.         {
  154.             ULONG f,g;
  155.     
  156.             g=GetRGB4(Scrn.Scrn->ViewPort.ColorMap,ca);
  157.             f= (g&0xf) + ((g>>4) &0xf)*2 + ((g>>8) &0xf)*2;
  158.             if (f < 25)
  159.             {
  160.                 f=Scrn.DrawInfo->dri_Pens[SHINEPEN];
  161.             }
  162.             else
  163.             {
  164.                 f=Scrn.DrawInfo->dri_Pens[SHADOWPEN];
  165.             }
  166.     
  167.             SetAPen(rp,f);
  168.             if (s==STATUS_OUT)
  169.             {
  170.                 ULONG wk=(w+2)/3;
  171.                 ULONG hk=(h+2)/3;
  172.         
  173.                 Move(rp,x+wk,y+hk);
  174.                 Draw(rp,x+w-wk,y+h-hk);
  175.                 Move(rp,x+w-wk,y+hk);
  176.                 Draw(rp,x+wk,y+h-hk);
  177.             }
  178.             else if (s==STATUS_IN)
  179.             {
  180.                 ULONG wk=(w+2)/3;
  181.                 ULONG hk=(h+2)/3;
  182.     
  183.                 DrawEllipse(rp,x+w/2,y+h/2,wk/2,hk/2);
  184.             }
  185.         }
  186.     }
  187.     else if (display_mode==DISPLAY_LETTER)
  188.     {
  189.         UBYTE txt[2];
  190.         UWORD *pens=Scrn.DrawInfo->dri_Pens;
  191.         UWORD f,b;
  192.  
  193.         rp->AreaPtrn=0;
  194.         rp->AreaPtSz=0;
  195.  
  196.         if (c!=0)
  197.         {
  198.             if (s==STATUS_OUT)
  199.             {
  200.                 f=pens[TEXTPEN];
  201.                 b=pens[BACKGROUNDPEN];
  202.             }
  203.             else if (s==STATUS_IN)
  204.             {
  205.                 f=pens[HIGHLIGHTTEXTPEN];
  206.                 b=pens[FILLPEN];
  207.             }
  208.             else
  209.             {
  210.                 f=pens[TEXTPEN];
  211.                 b=pens[FILLPEN];
  212.             }
  213.             SetAPen(rp,b);
  214.             RectFill(rp,x+2,y+2,x+w-2,y+h-2);
  215.  
  216.             txt[0]='A'+c-1;
  217.             txt[1]=0;
  218.  
  219.             Txt_PrintFit(rp,txt,1,x+2,y+2,w-2,h-2,f,b,BOX_CENTER);
  220.         }
  221.         else
  222.         {
  223.             SetAPen(rp,pens[BACKGROUNDPEN]);
  224.             RectFill(rp,x+2,y+2,x+w-2,y+h-2);
  225.         }
  226.     }
  227. }
  228. //-------------------------------------
  229. void draw_thinbordervalue(struct RastPort *rp,LONG c,LONG x,LONG y, LONG w, LONG h,ULONG border)
  230. {
  231.     LONG s=0;
  232.     LONG f;
  233.  
  234.     draw_thinborder(rp,x,y,w,h,border);
  235.  
  236.     w--;
  237.     h--;
  238.  
  239.     rp->AreaPtrn=0;
  240.     rp->AreaPtSz=0;
  241.  
  242.     switch(c)
  243.     {
  244.         case BLACK:        f=Scrn.DrawInfo->dri_Pens[SHADOWPEN];break;
  245.         case WHITE:        f=Scrn.DrawInfo->dri_Pens[SHINEPEN];break;
  246.         default:            f=Scrn.DrawInfo->dri_Pens[BACKGROUNDPEN];break;
  247.     }
  248.  
  249.     SetAPen(rp,f);
  250.     RectFill(rp,x+2,y+2,x+w-2,y+h-2);
  251.  
  252. }
  253. //-------------------------------------
  254.  
  255. #define LIBV39        (39)
  256. //-------------------------------------
  257. struct BitMap *tkAllocBitMap(ULONG width,ULONG height,ULONG depth,ULONG flags,struct BitMap *like_bitmap)
  258. {
  259.     struct BitMap *bitmap=0;
  260.  
  261.     if (GfxBase->lib_Version>=LIBV39)
  262.     {
  263.         bitmap=AllocBitMap(width,height,depth,flags,like_bitmap);
  264.     }
  265.     else
  266.     {
  267.         ULONG t;
  268.  
  269.         bitmap=(struct BitMap*)Memory_Alloc(sizeof(struct BitMap));
  270.  
  271.         InitBitMap(bitmap,depth,width,height);
  272.  
  273.         for (t=0;t<depth;t++)
  274.         {
  275.             bitmap->Planes[t]=AllocRaster(width,height);
  276.             if (bitmap->Planes[t]) BltClear(bitmap->Planes[t],(bitmap->BytesPerRow<<16|bitmap->Rows),0x3);
  277.         }
  278.     }
  279.  
  280.     return bitmap;
  281. }
  282. //-------------------------------------
  283. void tkFreeBitMap(struct BitMap *bitmap)
  284. {
  285.     if (GfxBase->lib_Version>=LIBV39)
  286.     {
  287.         FreeBitMap(bitmap);
  288.     }
  289.     else
  290.     {
  291.         ULONG t;
  292.  
  293.         for (t=0;t<8;t++)
  294.         {
  295.             if (bitmap->Planes[t])
  296.             {
  297.                 FreeRaster(bitmap->Planes[t],bitmap->BytesPerRow*8,bitmap->Rows);
  298.             }
  299.         }
  300.         Memory_Free((UBYTE**)&bitmap);
  301.     }
  302. }
  303. //-------------------------------------
  304. ULONG tkGetBitMapAttr(struct BitMap *bitmap,ULONG attr)
  305. {
  306.     ULONG res=0;
  307.  
  308.     if (GfxBase->lib_Version>=LIBV39)
  309.     {
  310.         res=GetBitMapAttr(bitmap,attr);
  311.     }
  312.     else
  313.     {
  314.         switch(attr)
  315.         {
  316.             case BMA_HEIGHT:
  317.                 res=bitmap->Rows;
  318.                 break;
  319.             case BMA_WIDTH:
  320.                 res=bitmap->BytesPerRow*8;
  321.                 break;
  322.             case BMA_DEPTH:
  323.                 res=bitmap->Depth;
  324.                 break;
  325.             case BMA_FLAGS:
  326.                 res=bitmap->Flags;
  327.                 break;
  328.         }    
  329.     }
  330.  
  331.     return res;
  332. }
  333. //-------------------------------------
  334.  
  335.  
  336. //-------------------------------------
  337. void icon_drag(ULONG c,ULONG *x,ULONG *y)
  338. {
  339.     struct Window *window=supercode_window;
  340.     struct BitMap *bitmap_sc=0;
  341.     struct BitMap *bitmap_ob=0;
  342.     struct BitMap *bitmap_bg=0;
  343.     struct Screen *screen=window->WScreen;
  344.     struct RastPort *rport_wi=window->RPort;
  345.     LONG depth;
  346.     LONG w=icon_w;
  347.     LONG h=icon_h;
  348.     LONG x1=(*x)-w/2;
  349.     LONG y1=(*y)-h/2;
  350.     LONG x2=x1;
  351.     LONG y2=y1;
  352.     LONG mask=0xff;
  353.  
  354.     struct IntuiMessage *msg;
  355.     LONG code=0,clas=0;
  356.  
  357.     if (screen)
  358.     {
  359. //        LockLayerInfo(&screen->LayerInfo);
  360.  
  361.         window->Flags|=WFLG_RMBTRAP;
  362.  
  363.         bitmap_sc=screen->RastPort.BitMap;
  364.         if (bitmap_sc)
  365.         {
  366.             depth=tkGetBitMapAttr(bitmap_sc,BMA_DEPTH);
  367.  
  368.             bitmap_ob=tkAllocBitMap(w,h+2,depth,BMF_CLEAR|BMF_INTERLEAVED,bitmap_sc);
  369.             bitmap_bg=tkAllocBitMap(w,h+2,depth,BMF_CLEAR|BMF_INTERLEAVED,bitmap_sc);
  370.  
  371.             rport_ob.BitMap=bitmap_ob;
  372.             rport_bg.BitMap=bitmap_bg;
  373.  
  374.             draw_thinborderfield(&rport_ob,c,0,1,w,h,FALSE);
  375.  
  376.             if (bitmap_ob && bitmap_bg)
  377.             {
  378.                 while (TRUE)
  379.                 {
  380. //                    WaitBlit();
  381.                     ClipBlit(rport_wi,x2,y2,
  382.                                 &rport_bg,0,1,w,h,ABNC|ABC);
  383.     
  384. //                    WaitBlit();
  385.                     ClipBlit(&rport_ob,0,1,
  386.                                 rport_wi,x2,y2,w,h,ABNC|ABC);
  387.  
  388.                     do
  389.                     {
  390.                         WaitPort(window->UserPort);
  391.                         msg=(struct IntuiMessage*)GetMsg(window->UserPort);
  392.                     } while (!msg);
  393.  
  394.                     x1 = x2;
  395.                     y1 = y2;
  396.                     x2 = msg->MouseX-w/2;
  397.                     y2 = msg->MouseY-h/2;
  398.  
  399.                     clas = msg->Class;
  400.                     code = msg->Code;
  401.  
  402.                     ReplyMsg((struct Message*)msg);
  403.  
  404. //                    WaitBlit();
  405.                     ClipBlit(&rport_bg,0,1,
  406.                                 rport_wi,x1,y1,w,h,ABNC|ABC);
  407.  
  408.                     if (clas==IDCMP_MOUSEBUTTONS)
  409.                     {
  410.                         if (code == 0xe8)
  411.                         {
  412.                             (*x)=x1+w/2;
  413.                             (*y)=y1+h/2;
  414.                             break; 
  415.                         }
  416.                         if (code == 0x69)
  417.                         {
  418.                             (*x)=-1;
  419.                             (*y)=-1;
  420.                             break; 
  421.                         }
  422.                     }
  423.                 }
  424.  
  425.                 tkFreeBitMap(bitmap_ob);
  426.                 tkFreeBitMap(bitmap_bg);
  427.             }
  428.         }
  429. //        UnlockLayerInfo(&screen->LayerInfo);
  430.  
  431.         window->Flags&=~WFLG_RMBTRAP;
  432.  
  433.     }
  434. }
  435. //-------------------------------------
  436.  
  437.  
  438. //-------------------------------------
  439. void supercode_clear()
  440. {
  441.     struct RastPort *rp=supercode_window->RPort;
  442.     ULONG x=pal.x,y=pal.y,w=pal.w,h=pal.h;
  443.  
  444.     EraseRect(rp,x,y,x+w-1,y+h-1);
  445.  
  446.     x=field.x;
  447.     y=field.y;
  448.     w=field.w;
  449.     h=field.h;
  450.     EraseRect(rp,x,y,x+w-1,y+h-1);
  451.  
  452.     x=value.x;
  453.     y=value.y;
  454.     w=value.w;
  455.     h=value.h;
  456.     EraseRect(rp,x,y,x+w-1,y+h-1);
  457. }
  458. //-------------------------------------
  459. void supercode_drawpalette()
  460. {
  461.     struct Window *win=supercode_window;
  462.  
  463.     LONG n=player1.num_colors;
  464.     LONG x=pal.x,y=pal.y,w=pal.w,h=pal.h;
  465.  
  466.     LONG w1,wg,t;
  467.  
  468.     pal.max=n-1;
  469.  
  470.     w1=w/n;
  471.     wg=w1*n;
  472.  
  473.     x+=(w-wg)/2;
  474.  
  475.     pal.xs=x;
  476.     pal.w1=w1;
  477.  
  478.     for (t=1;t<=n;t++)
  479.     {
  480.         draw_thinborderfield(win->RPort,t,x,y,w1-2,h,0);
  481.         x+=w1;
  482.     }
  483.  
  484.  
  485. }
  486. //-------------------------------------
  487. void supercode_drawfield(BOOL drawlast)
  488. {
  489.     struct GameEntry *entry=code_getlsttry(&player1);
  490.     struct Window *win=supercode_window;
  491.  
  492.     LONG nx=player1.columns;
  493.     LONG ny=player1.lines;
  494.     LONG xf=field.x,y,wf=field.w,h=field.h;
  495.     LONG xv=value.x,wv=value.w;
  496.  
  497.     LONG h1,t;
  498.     LONG wf1,wfg,xf2;
  499.     LONG wv1,wvg,xv2;
  500.     LONG s=1,cf,cv;
  501.     LONG border=0;
  502.  
  503.     field.max=nx-1;
  504.  
  505.     wf1=wf/nx;
  506.     wfg=wf1*nx;
  507.  
  508.     wv1=wv/nx;
  509.     wvg=wv1*nx;
  510.  
  511.     h1=wf1*2/3*Scrn.Ymul+2;
  512.     h1=MAX(10,h1);
  513.     h1=MIN(20,h1);
  514.  
  515.     y=field.y+field.h-h1;
  516.  
  517.     icon_w=wf1+2;
  518.     icon_h=h1+2;
  519.  
  520.     xf+=(wf-wfg)/2;
  521.     xv+=(wv-wvg)/2;
  522.     xf2=xf;
  523.     xv2=xv;
  524.  
  525.     field.xs=xf;
  526.     field.w1=wf1;
  527.     field.h1=value.h1=h1;
  528.     value.xs=xv;
  529.     value.w1=wv1;
  530.  
  531.     while (y>field.y)
  532.     {
  533.         xf=xf2;
  534.         xv=xv2;
  535.         if (entry)
  536.         {
  537.             for (t=0;t<nx;t++)
  538.             {
  539.                 cf=code_getfield(&player1,entry,t);
  540.                 cv=code_getvalue(&player1,entry,t);
  541.  
  542.                 if (code_getnexttry(entry)) border=1;
  543.                 else border=0;
  544.     
  545.                 draw_thinborderfield(win->RPort,cf,xf,y,wf1-1,h1-3,border);
  546.                 if (player1.giveup && border==0 )
  547.                 {
  548.                     if (t==0)
  549.                     {
  550.                         EraseRect(win->RPort,xv,y,xv+wv-1,y+h1-1);
  551.                     }
  552.                 }
  553.                 else
  554.                 {
  555.                     draw_thinbordervalue(win->RPort,cv,xv,y,wv1-1,h1-3,border);
  556.                 }
  557.                 xf+=wf1;
  558.                 xv+=wv1;
  559.             }
  560.         }
  561.         else
  562.         {
  563.             EraseRect(win->RPort,xf,y,xf+wfg-1,y+h1-1);
  564.             EraseRect(win->RPort,xv,y,xv+wvg-1,y+h1-1);
  565.         }
  566.  
  567.         y-=h1;
  568.         s++;
  569.  
  570.         if (drawlast) break;
  571.         if (entry) entry=code_getprevtry(entry);
  572.  
  573.     }
  574.     if (!drawlast) SetGadgetAttrs(gadget_comb,supercode_window,0,GA_Integer,code_getpoints(&player1),TAG_END);
  575. }
  576. //-------------------------------------
  577. void supercode_drawall()
  578. {
  579.     supercode_drawpalette();
  580.     supercode_drawfield(FALSE);
  581.     SetGadgetAttrs(gadget_name,supercode_window,0,GA_Text,prg_prefs->game.player_name,TAG_END);
  582.     SetGadgetAttrs(gadget_name,supercode_window,0,GA_Text,prg_prefs->game.player_name,TAG_END);
  583. }
  584. //-------------------------------------
  585. void supercode_gfxmake()
  586. {
  587.     struct Window *win=supercode_window;
  588.     struct TextFont *font=Scrn.tkfont.font;
  589.  
  590.     if (win)
  591.     {
  592.         ULONG
  593.             rx,ry,hb,
  594.             bl,bt,br,bb,
  595.             ys,
  596.             w,h,hp,
  597.             xg,yg,wg,hg,
  598.             xp,yp,wp,
  599.             xb,yb,wb,
  600.             wb1;
  601.  
  602.         rx=4;
  603.         ry=4;
  604.         hb=font->tf_YSize+2*ry;
  605.  
  606.         bl=win->BorderLeft+rx;
  607.         bt=win->BorderTop+ry+hb+ry;
  608.         br=win->BorderRight+rx;
  609.         bb=win->BorderBottom+ry;
  610.  
  611.         ys=win->BorderTop+ry;
  612.  
  613.         w=win->Width-bl-br;
  614.         h=win->Height-bt-bb;
  615.  
  616.         hp=w/player1.num_colors*2/3;
  617.         hp=MAX(16,hp);
  618.         hp=MIN(25,hp);
  619.  
  620.         xg=bl;yg=bt;wg=w;hg=h-ry-hb-ry-hp;
  621.         xp=bl;yp=bt+hg+ry;wp=w;
  622.  
  623.         xb=bl;yb=bt+hg+ry+hp+ry;wb=w;
  624.  
  625.         DrawBevelBox(win->RPort,xg,yg,wg,hg,
  626.             GT_VisualInfo,Scrn.Visual,
  627.             GTBB_FrameType,BBFT_RIDGE,
  628.             GTBB_Recessed,TRUE,
  629.             TAG_END);
  630.  
  631.         xg+=4+rx;
  632.         yg+=2+ry;
  633.         wg-=2*(4+rx);
  634.         hg-=2*(2+ry);
  635.  
  636.         field.x=xg;
  637.         field.y=yg;
  638.         field.w=wg*2/3-rx;
  639.         field.h=hg;
  640.  
  641.         value.x=xg+field.w+rx;
  642.         value.y=yg;
  643.         value.w=wg-field.w-rx;
  644.         value.h=hg;
  645.  
  646.         wb1=wb/3;
  647.  
  648.         pal.x=xp+4;
  649.         pal.y=yp+2;
  650.         pal.w=wp-8;
  651.         pal.h=hp-4;
  652.  
  653.         DrawBevelBox(win->RPort,xp,yp,wp,hp,
  654.             GT_VisualInfo,Scrn.Visual,
  655.             GTBB_FrameType,BBFT_BUTTON,
  656.             GTBB_Recessed,TRUE,
  657.             TAG_END);
  658.  
  659.         DrawBevelBox(win->RPort,field.x,field.y,field.w,field.h,
  660.             GT_VisualInfo,Scrn.Visual,
  661.             GTBB_FrameType,BBFT_BUTTON,
  662.             GTBB_Recessed,TRUE,
  663.             TAG_END);
  664.         DrawBevelBox(win->RPort,value.x,value.y,value.w,value.h,
  665.             GT_VisualInfo,Scrn.Visual,
  666.             GTBB_FrameType,BBFT_BUTTON,
  667.             GTBB_Recessed,TRUE,
  668.             TAG_END);
  669.  
  670.         gadget_1st =
  671.         gadget_new = NewObject (class_button,0,
  672.             GA_Left,xb,
  673.             GA_Top,yb,
  674.             GA_Width,wb1-rx,
  675.             GA_Height,hb,
  676. //            GA_Previous,0,
  677.             GA_RelVerify,TRUE,
  678.             GA_Text,CatStr(TXT_WINGADNEW),
  679.             GA_ID,ID_NEW,
  680.             GA_Font,font,
  681.             TAG_END);
  682.  
  683.         xb+=wb1;
  684.         gadget_solve = NewObject (class_button,0,
  685.             GA_Previous,gadget_new,
  686.             GA_Left,xb,
  687.             GA_Top,yb,
  688.             GA_Width,wb1,
  689.             GA_Height,hb,
  690.             GA_RelVerify,TRUE,
  691.             GA_Text,CatStr(TXT_WINGADGIVEUP),
  692.             GA_ID,ID_SOLVE,
  693.             GA_Font,font,
  694.             TAG_END);
  695.  
  696.         xb+=wb1+rx;
  697.         gadget_score = NewObject (class_button,0,
  698.             GA_Previous,gadget_solve,
  699.             GA_Left,xb,
  700.             GA_Top,yb,
  701.             GA_Width,wb1-rx,
  702.             GA_Height,hb,
  703.             GA_RelVerify,TRUE,
  704.             GA_Text,CatStr(TXT_WINGADHIGHSCORE),
  705.             GA_ID,ID_SCORE,
  706.             GA_Font,font,
  707.             TAG_END);
  708.  
  709.         xb=bl;
  710.         wb1=wb/4;
  711.         gadget_name = NewObject (class_text,0,
  712.             GA_Previous,gadget_score,
  713.             GA_Left,xb,
  714.             GA_Top,ys,
  715.             GA_Width,wb1*2-rx,
  716.             GA_Height,hb,
  717.             GA_Text,prg_prefs->game.player_name,
  718.             GA_TextJust,BOX_CENTER,
  719.             GA_Font,font,
  720.             TAG_END);
  721.  
  722.         xb+=wb1*2;
  723.         gadget_comb = NewObject (class_text,0,
  724.             GA_Previous,gadget_name,
  725.             GA_Left,xb,
  726.             GA_Top,ys,
  727.             GA_Width,wb1,
  728.             GA_Height,hb,
  729.             GA_Integer,code_getpoints(&player1),
  730.             GA_TextJust,BOX_CENTER,
  731.             GA_Font,font,
  732.             TAG_END);
  733.  
  734.         xb+=wb1+rx;
  735.         gadget_time = NewObject (class_text,0,
  736.             GA_Previous,gadget_comb,
  737.             GA_Left,xb,
  738.             GA_Top,ys,
  739.             GA_Width,wb1-rx,
  740.             GA_Height,hb,
  741.             GA_Text,0,
  742.             GA_TextJust,BOX_CENTER,
  743.             GA_Font,font,
  744.             TAG_END);
  745.  
  746.         field.x+=2+2;
  747.         field.y+=1+1;
  748.         field.w-=4+4;
  749.         field.h-=2+2;
  750.  
  751.         value.x+=2+2;
  752.         value.y+=1+1;
  753.         value.w-=4+4;
  754.         value.h-=2+2;
  755.  
  756.         supercode_drawall();
  757.  
  758.         AddGList(win,gadget_new,-1,-1,0);
  759.         RefreshGList(gadget_new,win,0,-1);
  760.     }
  761. }
  762. //-------------------------------------
  763. void supercode_gfxclr()
  764. {
  765. #define DisposeGadget(g)    if (g) DisposeObject(g);
  766.     struct Window *win=supercode_window;
  767.  
  768.     RemoveGList(win,gadget_1st,-1);
  769.  
  770.     DisposeGadget(gadget_new);
  771.     DisposeGadget(gadget_solve);
  772.     DisposeGadget(gadget_score);
  773.     DisposeGadget(gadget_name);
  774.     DisposeGadget(gadget_comb);
  775.     DisposeGadget(gadget_time);
  776.  
  777.     RefreshWindowFrame(win);
  778.     EraseRect(win->RPort,win->BorderLeft,win->BorderTop,win->Width-win->BorderRight-1,win->Height-win->BorderBottom-1);
  779.  
  780.     supercode_gfxmake();
  781. }
  782. //-------------------------------------
  783.  
  784.  
  785. //-------------------------------------
  786. void supercode_inputname()
  787. {
  788.     struct Window *supercode_name;
  789.     struct Requester req;
  790.     LONG h=30;
  791.  
  792.     InitRequester(&req);
  793.  
  794.     req.LeftEdge=-1;
  795.     req.TopEdge=-1;
  796.     req.Width=1;
  797.     req.Height=1;
  798.  
  799.     Request(&req,supercode_window);
  800.  
  801.     supercode_name=OpenWindowTags(0,
  802.         WA_Title,CatStr(TXT_WINTITLENAME),
  803.         WA_Left,supercode_window->LeftEdge,
  804.         WA_Top,supercode_window->TopEdge + supercode_window->BorderTop,
  805.         WA_Width,supercode_window->Width,
  806.         WA_InnerHeight,h,
  807.         (Scrn.Scrn && Scrn.FlgPublic==FALSE) ? WA_CustomScreen : WA_PubScreen,Scrn.Scrn,
  808.         WA_Flags,
  809.                 WFLG_ACTIVATE|
  810.                 WFLG_CLOSEGADGET|
  811.                 WFLG_DRAGBAR|
  812.                 WFLG_DEPTHGADGET|
  813.                 WFLG_NEWLOOKMENUS|
  814.                 0,
  815.         WA_IDCMP,
  816.                 IDCMP_GADGETUP|
  817.                 IDCMP_CLOSEWINDOW|
  818.                 0,
  819.         WA_AutoAdjust,TRUE,
  820.         TAG_END);
  821.  
  822.     if (supercode_name)
  823.     {
  824.         struct Window *win=supercode_name;
  825.         struct Gadget *gad_name;
  826.         struct IntuiMessage *msg;
  827.     
  828.         struct Gadget *gadg;
  829.         LONG clas;
  830.         LONG ready=FALSE;
  831.         APTR border;
  832.         LONG w=win->Width-win->BorderLeft-win->BorderRight;
  833.         LONG x=win->BorderLeft;
  834.         LONG y=win->BorderTop;
  835.  
  836.         h-=8;
  837.         x+=6;w-=8;
  838.         y+=5;
  839.         border = NewObject(0,FRAMEICLASS,
  840.             IA_Left,-4,
  841.             IA_Top,-2,
  842.             IA_Width,w,
  843.             IA_Height,h,
  844.             IA_FrameType,FRAME_RIDGE,
  845.             TAG_END);
  846.         w-=8;
  847.         h-=4;
  848.         gad_name = NewObject (0,STRGCLASS,
  849.             GA_Image,border,
  850. //            GA_Previous,0,
  851.             GA_Left,x,
  852.             GA_Top,y,
  853.             GA_Width,w,
  854.             GA_Height,h,
  855.             GA_RelVerify,TRUE,
  856.             STRINGA_Buffer,prg_prefs->game.player_name,
  857.             STRINGA_MaxChars,MAX_PLAYERNAME,
  858.             STRINGA_BufferPos,0,
  859.             STRINGA_DispPos,0,
  860.             STRINGA_Justification,GACT_STRINGCENTER,
  861.             TAG_END);
  862.  
  863.         AddGList(win,gad_name,-1,-1,0);
  864.         RefreshGList(gad_name,win,0,-1);
  865.         ActivateGadget(gad_name,win,0);
  866.  
  867.         while (!ready)
  868.         {
  869.             WaitPort(win->UserPort);
  870.             msg=(struct IntuiMessage*)GetMsg(win->UserPort);
  871.  
  872.             gadg = (APTR)msg->IAddress;
  873.             clas = msg->Class;
  874.  
  875.             ReplyMsg((struct Message*)msg);
  876.     
  877.             switch (clas)
  878.             {
  879.                 case IDCMP_CLOSEWINDOW:
  880.                     ready=TRUE;
  881.                     break;
  882.                 case IDCMP_GADGETUP:
  883.                     ready=TRUE;
  884.                     break;
  885.             }
  886.         }
  887.         RemoveGList(win,gad_name,-1);
  888.  
  889.         if (gad_name)    DisposeObject(gad_name);
  890.         if (border)        DisposeObject(border);
  891.  
  892.         CloseWindow(supercode_name);
  893.     }
  894.     EndRequest(&req,supercode_window);
  895.  
  896.     SetGadgetAttrs(gadget_name,supercode_window,0,GA_Text,prg_prefs->game.player_name,TAG_END);
  897. //    RefreshGList(gadget_name,supercode_window,0,1);
  898.     
  899. }
  900. //-------------------------------------
  901.  
  902.  
  903. //-------------------------------------
  904. void supercode_compare()
  905. {
  906.     if (!player1.finish)
  907.     {
  908.         code_comparelast(&player1);
  909.         supercode_drawfield(FALSE);
  910.  
  911.         if (player1.finish)
  912.         {
  913.             score_add(&player1,prg_prefs->game.player_name);
  914.         }
  915.     }
  916. }
  917. //-------------------------------------
  918.  
  919.  
  920. //-------------------------------------
  921. void supercode_createtable()
  922. {
  923.     ULONG t,a=0,b=0;
  924.     ULONG n=player1.num_colors;
  925.     BOOL m;
  926.  
  927.     Memory_Free((UBYTE**)&color_tabl);
  928.     Memory_Free(&color_stat);
  929.     color_tabl=(UWORD*)Memory_Alloc(n*2+2);
  930.     color_stat=Memory_Alloc(n+2);
  931.  
  932.     color_tabl[0]=0;
  933.  
  934.     a=0;
  935.     b=0;
  936.     m=FALSE;
  937.     for(t=1;t<=n;t++)
  938.     {
  939.         if (m)
  940.         {
  941.             if (Reg_Col[a]==0xffff)
  942.             {
  943.                 b++;
  944.                 if (Reg_Col[b]==0xffff) break;
  945.                 a=b+1;
  946.                 if (Reg_Col[a]==0xffff) break;
  947.             }
  948.         }
  949.         else
  950.         {
  951.             b=a;    
  952.             if (Reg_Col[a]==0xffff)
  953.             {
  954.                 m=TRUE;
  955.                 a=1;
  956.                 b=0;
  957.             }
  958.         }
  959.  
  960.         color_tabl[t] = Reg_Col[a] << 8 | Reg_Col[b];
  961.         color_stat[t] = 0;
  962.  
  963.         a++;
  964.     }
  965.     if (display_mode==DISPLAY_COLORS)
  966.         if (t<=n) display_mode=DISPLAY_LETTER;
  967. }
  968. //-------------------------------------
  969.  
  970. ULONG last_sec,last_mic;
  971. ULONG frst_sec,frst_mic;
  972.  
  973. //-------------------------------------
  974. void supercode_newgame()
  975. {
  976.     struct Window *win=supercode_window;
  977.     long min_width1;
  978.     long min_width2;
  979.     long width=win->Width;
  980.  
  981.     code_newcomb(&player1);
  982.     supercode_createtable();
  983.     min_width1=win->BorderLeft+4+4+6+player1.columns*7+4+4+4+player1.columns*7+6+4+4+win->BorderRight;
  984.     min_width2=win->BorderLeft+4+4+6+player1.num_colors*10+6+4+4+win->BorderRight;
  985.     width=MAX(min_width1,min_width2);
  986.  
  987.     if ( win->Width < width )
  988.     {
  989.         SizeWindow(win,width-win->Width,0);
  990.         WindowLimits(win,width,0,0,0);
  991.     }
  992.     else
  993.     {
  994.         WindowLimits(win,width,0,0,0);
  995.         supercode_clear();
  996.         supercode_drawall();
  997.     }
  998.     if (gadget_time) SetGadgetAttrs(gadget_time,supercode_window,0,GA_Text,"0:00:00",TAG_END);
  999. }
  1000. //-------------------------------------
  1001. void supercode_newplayer()
  1002. {
  1003.     supercode_inputname();
  1004.     supercode_newgame();
  1005. }
  1006. //-------------------------------------
  1007. void supercode_giveup()
  1008. {
  1009.     code_giveup(&player1);
  1010.     supercode_drawfield(TRUE);
  1011. }
  1012. //-------------------------------------
  1013.  
  1014.  
  1015. //-------------------------------------
  1016. void supercode_dogadget(ULONG id,ULONG qual)
  1017. {
  1018.     switch (id)
  1019.     {
  1020.         case ID_NEW:
  1021.             if (qual & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))
  1022.             {
  1023.                 supercode_newplayer();
  1024.             }
  1025.             {
  1026.                 supercode_newgame();
  1027.             }
  1028.             break;
  1029.         case ID_SCORE:
  1030.             score_display();
  1031.             break;
  1032.         case ID_SOLVE:
  1033.             supercode_giveup();
  1034.             break;
  1035.         case ID_COMP:
  1036.             supercode_compare();
  1037.             break;
  1038.     }
  1039. }
  1040. //-------------------------------------
  1041. BOOL in_range(ULONG mx,ULONG my,struct box *box)
  1042. {
  1043.     ULONG x=box->x;
  1044.     ULONG y=box->y;
  1045.     ULONG w=box->w;
  1046.     ULONG h=box->h;
  1047.     ULONG xe=x+w-1;
  1048.     ULONG ye=y+h-1;
  1049.     ULONG res=FALSE;
  1050.  
  1051.     if ( mx >= x && mx <=xe )
  1052.         if ( my >= y && my <=ye ) res=TRUE;
  1053.  
  1054.     return res;
  1055. }
  1056. //-------------------------------------
  1057. void supercode_mouseclick(ULONG code,ULONG qual,ULONG x,ULONG y)
  1058. {
  1059.     LONG p=0;
  1060.     LONG col=0;
  1061.  
  1062.     if (!player1.finish)
  1063.     {
  1064.         if (code == 0x68) ModifyIDCMP(supercode_window,supercode_window->IDCMPFlags | IDCMP_MOUSEMOVE);
  1065.         if (code == 0xE8) ModifyIDCMP(supercode_window,supercode_window->IDCMPFlags & ~IDCMP_MOUSEMOVE);
  1066.  
  1067.         if (in_range(x,y,&field))
  1068.         {
  1069.             LONG px,py;
  1070.  
  1071.             px=(x-field.xs)/field.w1;
  1072.             py=(field.y+field.h-y)/field.h1;
  1073.     
  1074.             if (px<0) px=0;
  1075.             if (px>field.max) px=field.max;
  1076.  
  1077.             if (code == 0x68)
  1078.             {
  1079.                 col=code_getfield(&player1,code_getnumtry(&player1,player1.lines-py),px);
  1080.             }
  1081.         }
  1082.         if (in_range(x,y,&pal))
  1083.         {
  1084.             p=(x-pal.xs)/pal.w1;
  1085.  
  1086.             if (p<0) p=0;
  1087.             if (p>pal.max) p=pal.max;
  1088.  
  1089.             if (code == 0x68)
  1090.             {
  1091.                 if (qual & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))
  1092.                 {
  1093.                     color_stat[p+1]++;
  1094.                     if (color_stat[p+1]>=STATUS_END) color_stat[p+1]=0;
  1095.                     supercode_drawall();
  1096.                 }
  1097.                 else
  1098.                 {
  1099.                     col=p+1;
  1100.                 }
  1101.             }
  1102.         }
  1103.         else if (in_range(x,y,&value))
  1104.         {
  1105.             if (code == 0xE8) supercode_dogadget(ID_COMP,qual);
  1106.         }
  1107.  
  1108.         if (col)
  1109.         {
  1110.             icon_drag(col,&x,&y);
  1111.  
  1112.             if (in_range(x,y,&field))
  1113.             {
  1114.                 x-=field.xs;
  1115.                 y-=field.y;
  1116.                 p=x/field.w1;
  1117.         
  1118.                 if (p<0) p=0;
  1119.                 if (p>field.max) p=field.max;
  1120.         
  1121.                 code_set(&player1,p,col);
  1122.                 supercode_drawfield(TRUE);
  1123.             }
  1124.         }
  1125.  
  1126.     }
  1127. }
  1128. //-------------------------------------
  1129.  
  1130.  
  1131. //-------------------------------------
  1132. void supercode_time(ULONG sec,ULONG mic)
  1133. {
  1134.     ULONG t=sec - player1.sec_start;
  1135.  
  1136.     if ((player1.started) && (!player1.finish) && (sec - last_sec)!=0)
  1137.     {
  1138.         ULONG h=(t/3600);
  1139.         ULONG m=(t-h*3600)/60;
  1140.         ULONG s=(t-m*60+h*3600);
  1141.         UBYTE timestr[10];
  1142.  
  1143.         sprintf(timestr,"%2.2d:%02.2d:%02.2d",h,m,s);
  1144.  
  1145.         SetGadgetAttrs(gadget_time,supercode_window,0,GA_Text,timestr,TAG_END)
  1146.     }
  1147.     last_sec=sec;
  1148.     last_mic=mic;
  1149. }
  1150. //-------------------------------------
  1151.  
  1152.  
  1153. //-------------------------------------
  1154. void supercode_about()
  1155. {
  1156.     display_error(TXT_ABOUT,ASK_OK,supercode_version,programmer_name,__DATE2__,prg_prefs->game.player_name);
  1157. }
  1158. //-------------------------------------
  1159.  
  1160.  
  1161. //-------------------------------------
  1162. LONG supercode_getbit()
  1163. {
  1164.     LONG bit=0;
  1165.  
  1166.     if (supercode_window)
  1167.     {
  1168.         bit=1 << supercode_window->UserPort->mp_SigBit;
  1169.     }
  1170.  
  1171.     return bit;
  1172. }
  1173. //-------------------------------------
  1174. VOID supercode_domsg()
  1175. {
  1176.     struct Window *win=supercode_window;
  1177.     struct IntuiMessage *msg;
  1178.  
  1179.     struct Gadget *gadg;
  1180.     LONG clas;
  1181.     LONG code;
  1182.     LONG qual;
  1183.     LONG posx,posy,seco,micr;
  1184.  
  1185.     while ((msg=(struct IntuiMessage*)GetMsg(win->UserPort)))
  1186.     {
  1187.         gadg = (APTR)msg->IAddress;
  1188.         clas = msg->Class;
  1189.         code = msg->Code;
  1190.         qual = msg->Qualifier;
  1191.         posx = msg->MouseX;
  1192.         posy = msg->MouseY;
  1193.         seco = msg->Seconds;
  1194.         micr = msg->Micros;
  1195.  
  1196.         ReplyMsg((struct Message*)msg);
  1197.  
  1198.         switch (clas)
  1199.         {
  1200.             case IDCMP_INTUITICKS:
  1201.                 supercode_time(seco,micr);
  1202.                 break;
  1203.             case IDCMP_CHANGEWINDOW:
  1204. //                supercode_StoreSize(MsgBlk);
  1205.                 break;
  1206.             case IDCMP_RAWKEY:
  1207.                 break;
  1208.             case IDCMP_SIZEVERIFY:
  1209.                 break;
  1210.             case IDCMP_NEWSIZE:
  1211.                 supercode_gfxclr();
  1212.                 break;
  1213.             case IDCMP_MENUPICK:
  1214.                 Command_Menu(Menu_Main.Menu,code);
  1215.                 break;
  1216.             case IDCMP_CLOSEWINDOW:
  1217.                 Quit();
  1218.                 break;
  1219.             case IDCMP_MOUSEMOVE:
  1220.             case IDCMP_MOUSEBUTTONS:
  1221.                 supercode_mouseclick(code,qual,posx,posy);
  1222.                 break;
  1223.             case IDCMP_GADGETDOWN:
  1224.             case IDCMP_GADGETUP:
  1225.                 supercode_dogadget(gadg->GadgetID,qual);
  1226.                 break;
  1227.             case IDCMP_INACTIVEWINDOW:
  1228.                 break;
  1229.         }
  1230.     }
  1231. }
  1232. //-------------------------------------
  1233.  
  1234. #define SAVEGAMEHEAD    'SAVE'
  1235. #define VIEWGAMEHEAD    'VIEW'
  1236. #define GAMECLR        'CLR '
  1237. #define GAMESTAT        'STAT'
  1238.  
  1239. #define PLYNAME        'NAME'
  1240. //-------------------------------------
  1241. void supercode_savegame()
  1242. {
  1243.     struct Field *player=&player1;
  1244.     struct GameEntry *entry=code_getcombi(player);
  1245.     struct tkfile *file;
  1246.  
  1247.     if (prefs_askfile(CatStr(TXT_SAVEGAMESAVE),prg_prefs->game.save_file,FILENAME_MAX,TRUE))
  1248.     {
  1249.         ULONG s,m;
  1250.  
  1251.         file = file_open(prg_prefs->game.save_file,MODE_NEWFILE,TRUE);
  1252.  
  1253.         if (file->file)
  1254.         {
  1255.             if (player->finish)
  1256.             {
  1257.                 file_writelong(file,VIEWGAMEHEAD);
  1258.             }
  1259.             else
  1260.             {
  1261.                 file_writelong(file,SAVEGAMEHEAD);
  1262.             }
  1263.     
  1264.             file_saveblock(file,PLYNAME,0,MAX_PLAYERNAME,prg_prefs->game.player_name);
  1265.     
  1266.             CurrentTime(&s,&m);
  1267.             m=player->sec_start;
  1268.             player->sec_start=s-player->sec_start;
  1269.     
  1270.             file_saveblock(file,GAMEPLAYER,VERGAMEPLAYER,sizeof(struct Field),player);
  1271.             file_saveblock(file,GAMEENTRY,VERGAMEENTRY,entry->size,entry);
  1272.         
  1273.             entry=code_get1sttry(player);
  1274.             while(entry)
  1275.             {
  1276.                 file_saveblock(file,GAMEENTRY,VERGAMEENTRY,entry->size,entry);
  1277.                 entry=code_getnexttry(entry);
  1278.             }
  1279.             file_saveblock(file,GAMESTAT,0,player->num_colors,color_stat);
  1280.     
  1281.             if (file->ok && !player->finish)
  1282.             {
  1283.                 supercode_newgame();
  1284.             }
  1285.         }
  1286.         file_free(&file);
  1287.     }
  1288. }
  1289. //-------------------------------------
  1290. void supercode_loadgame()
  1291. {
  1292.     struct Field *player=&player1;
  1293.     struct tkfile *file;
  1294.     ULONG c=0;
  1295.     BOOL load=TRUE;
  1296.     ULONG ind=0;
  1297.     struct GameEntry *new;
  1298.  
  1299.  
  1300.     if (prefs_askfile(CatStr(TXT_SAVEGAMELOAD),prg_prefs->game.save_file,FILENAME_MAX,FALSE))
  1301.     {
  1302.         file = file_open(prg_prefs->game.save_file,0,0);
  1303.         ind=file_readlong(file);
  1304.  
  1305.         if (ind==SAVEGAMEHEAD || ind==VIEWGAMEHEAD)
  1306.         {
  1307.             if (ind==VIEWGAMEHEAD || (ASK_OK==(display_error(TXT_ASKFORFILECLEAR,ASK_OK|ASK_ABORT))))
  1308.             {
  1309.                 code_freefield(player);
  1310.  
  1311.                 while (load)
  1312.                 {
  1313.                     ind=file_readlong(file);
  1314.         
  1315.                     switch(ind)
  1316.                     {
  1317.                         case PLYNAME:
  1318.                             file_loadblock(file,0,MAX_PLAYERNAME,prg_prefs->game.player_name);
  1319.                             break;
  1320.                         case GAMEPLAYER:
  1321.                             c=1;
  1322.                             file_loadblock(file,VERGAMEPLAYER,sizeof(struct Field),player);
  1323.                             List_Init(&player->try,NT_TRY,0);
  1324.                             supercode_createtable();
  1325.                             break;
  1326.                         case GAMESTAT:
  1327.                             if (c)
  1328.                             {
  1329.                                 file_loadblock(file,0,player->num_colors,color_stat);
  1330.                             }
  1331.                             break;
  1332.                         case GAMEENTRY:
  1333.                             if (c)
  1334.                             {
  1335.                                 LONG size=sizeof(struct GameEntry)+2*player->columns;
  1336.  
  1337.                                 c++;
  1338.                                 new=(struct GameEntry*)Memory_Alloc(size);
  1339.                                 file_loadblock(file,VERGAMEENTRY,size,new);
  1340.  
  1341.                                 new->field=((UBYTE*)new)+sizeof(struct GameEntry);
  1342.                                 new->value=((UBYTE*)new)+sizeof(struct GameEntry)+player->columns;
  1343.         
  1344.                                 List_AddTail(&player->try,&new->node);
  1345.                             }
  1346.                             break;
  1347.                         case GAMECLR:
  1348.                         default:
  1349.                             load=FALSE;
  1350.                             break;
  1351.                     }
  1352.                 }
  1353.             }
  1354.         }
  1355.         file_free(&file);
  1356.  
  1357.         if (c)
  1358.         {
  1359.             ULONG s,m;
  1360.             CurrentTime(&s,&m);
  1361.             player->sec_start=s-player->sec_start;
  1362.  
  1363.             supercode_drawall();
  1364.  
  1365.             if (!player->finish)
  1366.             {
  1367.                 file = file_open(prg_prefs->game.save_file,MODE_NEWFILE,0);
  1368.                 file_writelong(file,GAMECLR);
  1369.                 file_free(&file);
  1370.                 file_delete(prg_prefs->game.save_file);
  1371.             }
  1372.         }
  1373.  
  1374.     }
  1375. }
  1376. //-------------------------------------
  1377.  
  1378.  
  1379. //-------------------------------------
  1380. void supercode_open()
  1381. {
  1382.     supercode_window=OpenWindowTags(0,
  1383.         WA_Title,CatStr(TXT_WINTITLE),
  1384.  
  1385.         WA_Left,prg_prefs->win.game.Xpos,
  1386.         WA_Top,prg_prefs->win.game.Ypos,
  1387.         WA_Width,prg_prefs->win.game.WinW,
  1388.         WA_Height,prg_prefs->win.game.WinH,
  1389.         (Scrn.Scrn && Scrn.FlgPublic==FALSE) ? WA_CustomScreen : WA_PubScreen,Scrn.Scrn,
  1390.         WA_Flags,
  1391.                 WFLG_ACTIVATE|
  1392.                 WFLG_CLOSEGADGET|
  1393.                 WFLG_DRAGBAR|
  1394.                 WFLG_DEPTHGADGET|
  1395.                 WFLG_NEWLOOKMENUS|
  1396. //                WFLG_NOCAREREFRESH entspricht dem Tag WA_NoCareRefresh;
  1397.                 WFLG_REPORTMOUSE|
  1398. //                WFLG_RMBTRAP entspricht dem Tag WA_RMBTrap;
  1399. //                WFLG_SIMPLE_REFRESH entspricht dem Tag WA_SimpleRefresh;
  1400.                 WFLG_SIZEBBOTTOM|
  1401. //                WFLG_SIZEBRIGHT entspricht dem Tag WA_SizeBRight;
  1402.                 WFLG_SIZEGADGET|
  1403. //                WFLG_SMART_REFRESH entspricht dem Tag WA_SmartRefresh;
  1404.                 0,
  1405.         WA_IDCMP,
  1406.                 IDCMP_MOUSEBUTTONS|
  1407. //                IDCMP_MOUSEMOVE|
  1408.                 IDCMP_GADGETDOWN|
  1409.                 IDCMP_GADGETUP|
  1410.                 IDCMP_CLOSEWINDOW|
  1411.                 IDCMP_NEWSIZE|
  1412.                 IDCMP_MENUPICK|
  1413.                 IDCMP_INTUITICKS|
  1414.                 0,
  1415. //        WA_Zoom,0,
  1416.         WA_AutoAdjust,TRUE,
  1417.         WA_MaxWidth,-1,
  1418.         WA_MaxHeight,-1,
  1419.         WA_MinWidth,100,
  1420.         WA_MinHeight,100,
  1421.         TAG_END);
  1422.  
  1423.     SetMenuStrip(supercode_window,Menu_Main.Menu);
  1424.  
  1425.     supercode_gfxmake();
  1426.  
  1427. }
  1428. //-------------------------------------
  1429. void supercode_close()
  1430. {
  1431.     if (supercode_window)
  1432.     {
  1433.         window_close(supercode_window,&prg_prefs->win.game);
  1434.     }
  1435. }
  1436. //-------------------------------------
  1437.  
  1438.  
  1439. //-------------------------------------
  1440. void supercode_init()
  1441. {
  1442.     supercode_createtable();
  1443.     InitRastPort(&rport_ob);
  1444.     InitRastPort(&rport_bg);
  1445.  
  1446. }
  1447. //-------------------------------------
  1448. void supercode_free()
  1449. {
  1450.     Memory_Free((UBYTE**)&color_tabl);
  1451.     Memory_Free(&color_stat);
  1452.     supercode_close();
  1453. }
  1454. //-------------------------------------
  1455.  
  1456.